<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="128px"
    >
      <el-form-item label="本地救援起步距离" prop="startDistance">
        <el-input
          v-model="queryParams.startDistance"
          placeholder="请输入本地救援起步距离"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="本地救援起步价" prop="startPrice">
        <el-input
          v-model="queryParams.startPrice"
          placeholder="请输入本地救援起步价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="本地救援分段价" prop="outPrice">
        <el-input
          v-model="queryParams.outPrice"
          placeholder="请输入本地救援分段价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="顺风车起步价" prop="expressStartPrice">
        <el-input
          v-model="queryParams.expressStartPrice"
          placeholder="请输入顺风车起步价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="顺风车分段价" prop="expressOutPrice">
        <el-input
          v-model="queryParams.expressOutPrice"
          placeholder="请输入顺风车分段价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="司机起步价" prop="driverStartPrice">
        <el-input
          v-model="queryParams.driverStartPrice"
          placeholder="请输入司机起步价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="司机分段价" prop="driverOutPrice">
        <el-input
          v-model="queryParams.driverOutPrice"
          placeholder="请输入司机分段价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="司机顺风车起步价" prop="driverExpressStartPrice">
        <el-input
          v-model="queryParams.driverExpressStartPrice"
          placeholder="请输入司机顺风车起步价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="司机顺风车分段价" prop="driverExpressOutPrice">
        <el-input
          v-model="queryParams.driverExpressOutPrice"
          placeholder="请输入司机顺风车分段价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="分佣" prop="giveaway">
        <el-input
          v-model="queryParams.giveaway"
          placeholder="请输入分佣"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="本地救援调度抽成" prop="commission">
        <el-input
          v-model="queryParams.commission"
          placeholder="请输入本地救援调度抽成"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="顺风车调度抽成" prop="expressCommission">
        <el-input
          v-model="queryParams.expressCommission"
          placeholder="请输入顺风车调度抽成"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['driver:trailer:type:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['driver:trailer:type:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['driver:trailer:type:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['driver:trailer:type:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="trailerList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="主键ID" align="center" prop="id" /> -->
      <el-table-column label="类型" align="center" prop="type" />
      <el-table-column
        label="本地救援起步距离"
        align="center"
        prop="startDistance"
      />
      <el-table-column
        label="本地救援起步价"
        align="center"
        prop="startPrice"
      />
      <el-table-column label="本地救援分段价" align="center" prop="outPrice" />
      <el-table-column
        label="顺风车起步价"
        align="center"
        prop="expressStartPrice"
      />
      <el-table-column
        label="顺风车分段价"
        align="center"
        prop="expressOutPrice"
      />
      <el-table-column
        label="司机起步价"
        align="center"
        prop="driverStartPrice"
      />
      <el-table-column
        label="司机分段价"
        align="center"
        prop="driverOutPrice"
      />
      <el-table-column
        label="司机顺风车起步价"
        align="center"
        prop="driverExpressStartPrice"
      />
      <el-table-column
        label="司机顺风车分段价"
        align="center"
        prop="driverExpressOutPrice"
      />
      <el-table-column label="分佣" align="center" prop="giveaway" />
      <el-table-column
        label="本地救援调度抽成"
        align="center"
        prop="commission"
      />
      <el-table-column
        label="顺风车调度抽成"
        align="center"
        prop="expressCommission"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['driver:trailer:type:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['driver:trailer:type:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改车辆类型收费标准对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body>
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="180px"
        :inline="true"
        class="demo-form-inline"
      >
        <el-divider content-position="center">基础信息配置</el-divider>
        <el-form-item label="车辆类型" prop="type">
          <el-input v-model="chargeVO.typeId" placeholder="请输入车辆类型" />
        </el-form-item>
        <!-- <el-form-item label="起步价包含公里数" prop="startDistance">
          <el-input-number
            :step="1"
            :max="10000"
            :min="0"
            type="number"
            v-model="form.startDistance"
            placeholder="请输入本地救援起步距离"
          />
        </el-form-item> -->

        <el-divider content-position="center">客戶费用标准</el-divider>
        <el-form-item label="起步距离" prop="startPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.userCharge.startDistance"
            placeholder="起步距离"
          />
        </el-form-item>
        <el-form-item label="本地救援起步价格" prop="startPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.userCharge.startPrice"
            placeholder="请输入本地救援起步价"
          />
        </el-form-item>
        <el-form-item label="超出起步公里数单价" prop="outPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.userCharge.outPrice"
            placeholder="超出起步公里数单价"
          />
        </el-form-item>

        <el-form-item label="顺风车起步价格" prop="expressStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.userCharge.expressStartPrice"
            placeholder="请输入顺风车起步价"
          />
        </el-form-item>
        <el-form-item label="顺风车超出公里数单价" prop="expressOutPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.userCharge.expressOutPrice"
            placeholder="请输入顺风车分段价"
          />
        </el-form-item>
        <el-divider content-position="center">司机费用标准</el-divider>
        <el-form-item label="起步距离" prop="driverStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.driverCharge.startDistance"
            placeholder="请输入本地救援起步价"
          />
        </el-form-item>
        <el-form-item label="本地救援起步价格" prop="driverStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.driverCharge.driverStartPrice"
            placeholder="请输入本地救援起步价"
          />
        </el-form-item>
        <el-form-item label="超出起步公里数单价" prop="driverOutPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.driverCharge.driverOutPrice"
            placeholder="请输入司机分段价"
          />
        </el-form-item>
        <el-form-item label="顺风车起步价" prop="driverExpressStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.driverCharge.driverExpressStartPrice"
            placeholder="请输入司机顺风车起步价"
          />
        </el-form-item>
        <el-form-item label="顺风车超出公里数单价" prop="driverExpressOutPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.driverCharge.driverExpressOutPrice"
            placeholder="请输入司机顺风车分段价"
          />
        </el-form-item>

        <el-divider content-position="center">服务商费用标准</el-divider>
        <el-form-item label="起步距离" prop="serviceStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.serviceCharge.startDistance"
            placeholder="请输入本地救援起步价"
          />
        </el-form-item>
        <el-form-item label="本地救援起步价格" prop="serviceStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.serviceCharge.serviceStartPrice"
            placeholder="请输入本地救援起步价"
          />
        </el-form-item>
        <el-form-item label="超出起步公里数单价" prop="serviceOutPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.serviceCharge.serviceOutPrice"
            placeholder="超出起步公里数单价"
          />
        </el-form-item>

        <el-form-item label="顺风车起步价格" prop="serviceExpressStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.serviceCharge.serviceExpressStartPrice"
            placeholder="请输入顺风车起步价"
          />
        </el-form-item>
        <el-form-item
          label="顺风车超出公里数单价"
          prop="serviceExpressOutPrice"
        >
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.serviceCharge.serviceExpressOutPrice"
            placeholder="请输入顺风车分段价"
          />
        </el-form-item>

        <el-divider content-position="center">个人合伙人费用标准</el-divider>
        <el-form-item label="起步距离" prop="serviceStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.individualCharge.startDistance"
            placeholder="请输入本地救援起步价"
          />
        </el-form-item>
        <el-form-item label="本地救援起步价格" prop="serviceStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.individualCharge.serviceStartPrice"
            placeholder="请输入本地救援起步价"
          />
        </el-form-item>
        <el-form-item label="超出起步公里数单价" prop="serviceOutPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.individualCharge.serviceOutPrice"
            placeholder="超出起步公里数单价"
          />
        </el-form-item>

        <el-form-item label="顺风车起步价格" prop="serviceExpressStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.individualCharge.serviceExpressStartPrice"
            placeholder="请输入顺风车起步价"
          />
        </el-form-item>
        <el-form-item
          label="顺风车超出公里数单价"
          prop="serviceExpressOutPrice"
        >
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.individualCharge.serviceExpressOutPrice"
            placeholder="请输入顺风车分段价"
          />
        </el-form-item>

        <el-form-item label="本地救援分佣方式" prop="serviceExpressOutPrice">
          <el-radio-group v-model="chargeVO.individualCharge.userGiveawayType">
            <el-radio :label="0">现金分佣</el-radio>
            <el-radio :label="1">比例分佣</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="分佣" prop="serviceStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.individualCharge.userGiveaway"
            placeholder="分佣"
          />
        </el-form-item>

        <el-form-item label="顺风车分佣方式" prop="serviceExpressOutPrice">
          <el-radio-group
            v-model="chargeVO.individualCharge.expressUserGiveawayType"
          >
            <el-radio :label="0">现金分佣</el-radio>
            <el-radio :label="1">比例分佣</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="分佣" prop="serviceStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.individualCharge.expressUserGiveaway"
            placeholder="分佣"
          />
        </el-form-item>

        <el-divider content-position="center">企业合伙人费用标准</el-divider>
        <el-form-item label="起步距离" prop="serviceStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.businessCharge.startDistance"
            placeholder="请输入本地救援起步价"
          />
        </el-form-item>
        <el-form-item label="本地救援起步价格" prop="serviceStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.businessCharge.serviceStartPrice"
            placeholder="请输入本地救援起步价"
          />
        </el-form-item>
        <el-form-item label="超出起步公里数单价" prop="serviceOutPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.businessCharge.serviceOutPrice"
            placeholder="超出起步公里数单价"
          />
        </el-form-item>

        <el-form-item label="顺风车起步价格" prop="serviceExpressStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.businessCharge.serviceExpressStartPrice"
            placeholder="请输入顺风车起步价"
          />
        </el-form-item>
        <el-form-item
          label="顺风车超出公里数单价"
          prop="serviceExpressOutPrice"
        >
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.businessCharge.serviceExpressOutPrice"
            placeholder="请输入顺风车分段价"
          />
        </el-form-item>

        <el-form-item label="本地救援分佣方式" prop="serviceExpressOutPrice">
          <el-radio-group v-model="chargeVO.businessCharge.userGiveawayType">
            <el-radio :label="0">现金分佣</el-radio>
            <el-radio :label="1">比例分佣</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="分佣" prop="serviceStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.businessCharge.userGiveaway"
            placeholder="分佣"
          />
        </el-form-item>

        <el-form-item label="顺风车分佣方式" prop="serviceExpressOutPrice">
          <el-radio-group
            v-model="chargeVO.businessCharge.expressUserGiveawayType"
          >
            <el-radio :label="0">现金分佣</el-radio>
            <el-radio :label="1">比例分佣</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="分佣" prop="serviceStartPrice">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.businessCharge.expressUserGiveaway"
            placeholder="分佣"
          />
        </el-form-item>

        <el-divider content-position="center">服务商用标准</el-divider>
        <el-form-item label="本地救援抽佣方式" prop="commission">
          <el-radio-group v-model="chargeVO.serviceCharge.commissionType">
            <el-radio :label="0">现金分佣</el-radio>
            <el-radio :label="1">比例分佣</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="本地救援调度抽成" prop="commission">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.serviceCharge.commission"
            placeholder="请输入本地救援调度抽成"
          />
        </el-form-item>

        <el-form-item label="顺风车抽佣方式" prop="commission">
          <el-radio-group
            v-model="chargeVO.serviceCharge.expressUserGiveawayType"
          >
            <el-radio :label="0">现金分佣</el-radio>
            <el-radio :label="1">比例分佣</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="顺风车调度抽成" prop="expressCommission">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.serviceCharge.expressUserGiveaway"
            placeholder="请输入顺风车调度抽成"
          />
        </el-form-item>
        <el-divider content-position="center">平台费用标准</el-divider>
        <el-form-item label="本地救援抽佣方式" prop="commission">
          <el-radio-group v-model="chargeVO.userCharge.userGiveawayType">
            <el-radio :label="0">现金分佣</el-radio>
            <el-radio :label="1">比例分佣</el-radio>
          </el-radio-group>
        </el-form-item>

        <el-form-item label="本地救援调度抽成" prop="commission">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.userCharge.userGiveawayType"
            placeholder="请输入本地救援调度抽成"
          />
        </el-form-item>

        <el-form-item label="顺风车抽佣方式" prop="commission">
          <el-radio-group v-model="chargeVO.userCharge.expressUserGiveawayType">
            <el-radio :label="0">现金分佣</el-radio>
            <el-radio :label="1">比例分佣</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="顺风车调度抽成" prop="expressCommission">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="chargeVO.userCharge.expressUserGiveaway"
            placeholder="请输入顺风车调度抽成"
          />
        </el-form-item>

        <!-- <el-divider content-position="center">合伙人分佣</el-divider>
        <el-form-item label="抽佣方式" prop="commission">
          <el-radio-group v-model="chargeVO.individualCharge">
            <el-radio :label="3">现金分佣</el-radio>
            <el-radio :label="6">比例分佣</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="个人合伙人分佣" prop="giveaway">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="form.individualGiveaway"
            placeholder="请输入分佣"
          />
        </el-form-item>

        <el-form-item label="企业合伙人分佣" prop="businessGiveaway">
          <el-input-number
            :precision="2"
            :step="1"
            :max="10000"
            :min="0"
            v-model="form.businessGiveaway"
            placeholder="请输入分佣"
          />
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listTrailer,
  getTrailer,
  delTrailer,
  addTrailer,
  updateTrailer,
  add,
} from "@/api/driver/trailer/type";

export default {
  name: "Trailer",
  data() {
    return {
      radio: "",
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 车辆类型收费标准表格数据
      trailerList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        type: null,
        startDistance: null,
        startPrice: null,
        outPrice: null,
        expressStartPrice: null,
        expressOutPrice: null,
        driverStartPrice: null,
        driverOutPrice: null,
        driverExpressStartPrice: null,
        driverExpressOutPrice: null,
        giveaway: null,
        commission: null,
        expressCommission: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      chargeVO: {
        businessCharge: {
          commission: 0,
          createBy: "",
          createTime: "",
          expressCommission: 0,
          expressOutPrice: 0,
          expressStartPrice: 0,
          giveaway: 0,
          id: 0,
          outPrice: 0,
          params: {},
          remark: "",
          startDistance: 0,
          startPrice: 0,
          updateBy: "",
          updateTime: "",
          userGiveaway: 0,
        },
        driverCharge: {
          commission: 0,
          createBy: "",
          createTime: "",
          expressCommission: 0,
          expressOutPrice: 0,
          expressStartPrice: 0,
          giveaway: 0,
          id: 0,
          outPrice: 0,
          params: {},
          remark: "",
          startDistance: 0,
          startPrice: 0,
          updateBy: "",
          updateTime: "",
          userGiveaway: 0,
        },
        individualCharge: {
          commission: 0,
          createBy: "",
          createTime: "",
          expressCommission: 0,
          expressOutPrice: 0,
          expressStartPrice: 0,
          giveaway: 0,
          id: 0,
          outPrice: 0,
          params: {},
          remark: "",
          startDistance: 0,
          startPrice: 0,
          updateBy: "",
          updateTime: "",
          userGiveaway: 0,
        },
        serviceCharge: {
          commission: 0,
          createBy: "",
          createTime: "",
          expressCommission: 0,
          expressOutPrice: 0,
          expressStartPrice: 0,
          giveaway: 0,
          id: 0,
          outPrice: 0,
          params: {},
          remark: "",
          startDistance: 0,
          startPrice: 0,
          updateBy: "",
          updateTime: "",
          userGiveaway: 0,
        },
        typeId: 0,
        userCharge: {
          commission: 0,
          createBy: "",
          createTime: "",
          expressCommission: 0,
          expressOutPrice: 0,
          expressStartPrice: 0,
          giveaway: 0,
          id: 0,
          outPrice: 0,
          params: {},
          remark: "",
          startDistance: 0,
          startPrice: 0,
          updateBy: "",
          updateTime: "",
          userGiveaway: 0,
        },
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询车辆类型收费标准列表 */
    getList() {
      this.loading = true;
      listTrailer(this.queryParams).then((response) => {
        this.trailerList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.chargeVO = {
        businessCharge: {
          commission: 0,
          commissionType: 0,
          createBy: "",
          createTime: "",
          expressCommission: 0,
          expressCommissionType: 0,
          expressGiveaway: 0,
          expressGiveawayType: 0,
          expressOutPrice: 0,
          expressStartPrice: 0,
          expressUserGiveaway: 0,
          expressUserGiveawayType: 0,
          giveaway: 0,
          giveawayType: 0,
          id: 0,
          outPrice: 0,
          params: {},
          remark: "",
          startDistance: 0,
          startPrice: 0,
          updateBy: "",
          updateTime: "",
          userGiveaway: 0,
          userGiveawayType: 0,
        },
        driverCharge: {
          commission: 0,
          commissionType: 0,
          createBy: "",
          createTime: "",
          expressCommission: 0,
          expressCommissionType: 0,
          expressGiveaway: 0,
          expressGiveawayType: 0,
          expressOutPrice: 0,
          expressStartPrice: 0,
          expressUserGiveaway: 0,
          expressUserGiveawayType: 0,
          giveaway: 0,
          giveawayType: 0,
          id: 0,
          outPrice: 0,
          params: {},
          remark: "",
          startDistance: 0,
          startPrice: 0,
          updateBy: "",
          updateTime: "",
          userGiveaway: 0,
          userGiveawayType: 0,
        },
        individualCharge: {
          commission: 0,
          commissionType: 0,
          createBy: "",
          createTime: "",
          expressCommission: 0,
          expressCommissionType: 0,
          expressGiveaway: 0,
          expressGiveawayType: 0,
          expressOutPrice: 0,
          expressStartPrice: 0,
          expressUserGiveaway: 0,
          expressUserGiveawayType: 0,
          giveaway: 0,
          giveawayType: 0,
          id: 0,
          outPrice: 0,
          params: {},
          remark: "",
          startDistance: 0,
          startPrice: 0,
          updateBy: "",
          updateTime: "",
          userGiveaway: 0,
          userGiveawayType: 0,
        },
        serviceCharge: {
          commission: 0,
          commissionType: 0,
          createBy: "",
          createTime: "",
          expressCommission: 0,
          expressCommissionType: 0,
          expressGiveaway: 0,
          expressGiveawayType: 0,
          expressOutPrice: 0,
          expressStartPrice: 0,
          expressUserGiveaway: 0,
          expressUserGiveawayType: 0,
          giveaway: 0,
          giveawayType: 0,
          id: 0,
          outPrice: 0,
          params: {},
          remark: "",
          startDistance: 0,
          startPrice: 0,
          updateBy: "",
          updateTime: "",
          userGiveaway: 0,
          userGiveawayType: 0,
        },
        typeId: 0,
        userCharge: {
          commission: 0,
          commissionType: 0,
          createBy: "",
          createTime: "",
          expressCommission: 0,
          expressCommissionType: 0,
          expressGiveaway: 0,
          expressGiveawayType: 0,
          expressOutPrice: 0,
          expressStartPrice: 0,
          expressUserGiveaway: 0,
          expressUserGiveawayType: 0,
          giveaway: 0,
          giveawayType: 0,
          id: 0,
          outPrice: 0,
          params: {},
          remark: "",
          startDistance: 0,
          startPrice: 0,
          updateBy: "",
          updateTime: "",
          userGiveaway: 0,
          userGiveawayType: 0,
        },
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加车辆类型收费标准";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getTrailer(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改车辆类型收费标准";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.chargeVO.businessCharge.id) {
            add(this.chargeVO).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            add(this.chargeVO).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除车辆类型收费标准编号为"' + ids + '"的数据项？')
        .then(function () {
          return delTrailer(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "driver/trailer/export",
        {
          ...this.queryParams,
        },
        `trailer_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
